
<script>
function addRel(){
	if ($("#word").val()=="" && $("#content").val()==""){
		alert("not allow empty");
		return false;
	}else{
		insertRel($("#word").val(),$("#content").val());
	
	}

}
function insertRel(words,content){
	var aw = words.split(",");
	 
	client.query('INSERT INTO words_rel SET content = ?',[content],function(err1, results1){
		if(results1.insertId != null){
			for (i=0;i<aw.length ;i++ )
			{
				updateRel(aw[i],results1.insertId);
			}
		}
	});
}
function updateRel(word,rel_id){
	client.query('update words SET rel_id = ? where word=? ',[rel_id,word],function(err1, results1){
		if(results1.affectedRows >0){
			layer.msg("save success affect "+results1.affectedRows+" rows ");
		}
	});
}
</script>
    <p>word: <input type="text" id="word" style="width:300px" /></p>
    <p>rel info: <textarea id="content" style="width:500px;height:200px" ></textarea></p>
	<input type="button" value="save" onclick="addRel();"/>
